<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
</head>
<body>
    <form action="#">
        <h3>登录</h3>
        <div>
            <label for="userName">用户名：</label>
            <input type="text" id="userName">
        </div>
        <div>
            <label for="userPass">密码：</label>
            <input type="password" id="userPass">
        </div>
        <div>
            <input type="button" value="登录" onclick="login()">
        </div>
    </form>
    <script src="./js/jquery-1.12.4.min.js"></script>
    <script>
        function login(){
            $.ajax({
                url:"/api/shop-user/users/login",
                method:"post",
                // contentType:"application/json",
                data:{
                    userName:$("#userName").val(),
                    userPass:$("#userPass").val()
                },
                success(data){
                    console.log(data);
                    if(data.status == 1){
                        document.cookie = "token="+data.data;
                        window.location = "index.html"
                    }else{
                        alert("登录失败");
                    }
                    
                }
            })
        }
    </script>
</body>
</html>